package cn.ad.enumration;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * User: shirongkang
 * Date: 2016/12/7
 * Time: 14:32
 * Desc:
 */
public enum  DeviceTypeEnum {
    DEVICE_TYPE_OTHER("DEVICE_TYPE_OTHER","其他移动设备"),//其他设备类型
    DEVICE_TYPE_MOBILE("DEVICE_TYPE_MOBILE","移动设备"),//移动设备
    DEVICE_TYPE_PC("DEVICE_TYPE_PC","PC");//PC

    private String description;
    private String value;
    private static java.util.LinkedHashMap<String,String> mappings;
    private static List<Dropdown> list;

    private synchronized static java.util.LinkedHashMap<String,String> getMappings() {
        if (mappings == null) {
            mappings = new java.util.LinkedHashMap<>();
            for (DeviceTypeEnum format : DeviceTypeEnum.values()) {
                mappings.put(format.value, format.description);
            }
        }
        return mappings;
    }
    public static LinkedHashMap<String,String> getMapping(){
        return getMappings();
    }

    private DeviceTypeEnum(String value, String description) {
        this.description = description;
        this.value = value;
    }
    public String getDescription() {
        return this.description;
    }
    
    public static List<Dropdown> getListModel(){
        return getList();
    }
    
    private synchronized static List<Dropdown> getList() {
        if (list == null) {
            list = new ArrayList<>();
            for (DeviceTypeEnum format : DeviceTypeEnum.values()) {
            	list.add(new Dropdown(format.value, format.description));
            }
        }
        return list;
    }
}
